package com.twu.biblioteca;

import com.google.common.base.Optional;

import java.util.ArrayList;

public class Authenticator {
    private ArrayList<User> users;

    public Authenticator(ArrayList<User> users) {
        this.users = users;
    }

    public Optional<User> login(LibraryNumber number, Password password) {
        for (User user : users) {
            if (user.getLibraryNumber().equals(number) && user.getPassword().equals(password)) {
                return Optional.of(user);
            }
        }

        return Optional.absent();
    }
}
